package com.ado.bazinga.core.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ado.bazinga.core.dal.dao.OrderMapper;
import com.ado.bazinga.core.dal.entity.Order;
import com.ado.bazinga.core.manager.OrderManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 *@author adonais
 *@date 2020年3月20日
 *@description OrderManagerImpl.java
**/
@Service(value = "orderManager")
public class OrderManagerImpl extends ServiceImpl<OrderMapper, Order> implements OrderManager {
	
	@Autowired
	private OrderMapper orderMapper ;

	@Override
	public List<Order> getOrders(int userId) {
		List<Order> orderList = orderMapper.getOrders(userId) ;
		return orderList;
	}

	@Override
	public boolean insert(Order order) {
		boolean flag = false ;
		int i = orderMapper.insert(order) ;
		if (i == 0) {
			flag = false ;
		} else {
			flag = true ;
		}
		return flag;
	}

	@Override
	public boolean deleteById(int orderId) {
		boolean flag = false ;
		int i = orderMapper.deleteByOrderId(orderId) ;
		if (i == 1) {
			flag = true ;
		}else {
			flag = false ;
		}
		return flag;
	}

	@Override
	public List<Order> getAllOrders() {
		List<Order> orders = orderMapper.getAllOrders() ;
		return orders;
	}

}
